package com.bbz.core.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class LambdaTest1 {
    public static void main(String[] args) {
        Remark remark = new Remark();
        remark.setActive("true");
        remark.setAuditID(6);
        remark.setCode("refundApplication");
        remark.setRPH(1);
        List<Remark> list = new ArrayList<>();
        list.add(remark);
        Remarks remarks = new Remarks();
        remarks.setRemark(list);
        ModularProduct mp = new ModularProduct();
        mp.setRemarks(remarks);
        mp.setProductId("1001");
        List<ModularProduct> listMp = new ArrayList<>();
        listMp.add(mp);
        SuperPNR superPNR = new SuperPNR();
        superPNR.setModularProducts(listMp);


        Predicate<Remark> ojSuperPNRPredicate = r ->
                r.getCode().equals("refundApplication")
                        && r.getActive().equals("true")
                        && r.getRPH() == 1;

        Predicate<ModularProduct> modularProductPredicate = modularProduct ->
                modularProduct.getProductId().equals("1001");


        int aa = superPNR.getModularProducts().stream().flatMapToInt(m ->
                m.getRemarks().getRemark().stream().filter(ojSuperPNRPredicate).mapToInt(Remark::getAuditID)
        ).findFirst().getAsInt();

        List<ModularProduct> list1 = superPNR.getModularProducts().stream()
                .filter(modularProductPredicate).collect(Collectors.toList());
        System.out.println(aa);
        System.out.println(list1);
    }
}
